#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/priority_queue.hpp>
using namespace __gnu_pbds;
#define pct __builtin_popcount
const int N=2e5+5;
using ll=long long;
using ul=unsigned long long;
using vt=vector<int>;
int T,n,m,a[N],b[N],f[N],ans;
vt lk[N];
struct dat{
    int v,k;
    void operator+=(const dat &z){
        v+=z.v,k+=z.k;
    }
    bool operator<(const dat &z)const{
        return v==z.v?k<z.k:v<z.v;
    }
};
__gnu_pbds::priority_queue<dat>h[N];
void dfs(int x){
    for(int y:lk[x]){
        auto it=lk[y].begin();
        while(*it!=x)++it;
        lk[y].erase(it),dfs(y);
        h[x].join(h[y]);
    }
    if(h[x].size()>1){
        dat at=h[x].top();h[x].pop();
        ++at.v,at+=h[x].top(),h[x].pop();
        if(at.k==2)at.k=1,h[x].push({1});
        h[x].push(at);
    }else{
        if(h[x].size()){
            dat at=h[x].top();h[x].pop();
            if(at.k)at.v+=2,at.k=0,h[x].push(at);
            else at.k=1,h[x].push(at);
        }else h[x].push({1});
    }
}
int main(){
    ios::sync_with_stdio(false),cin.tie(0);
    freopen("bird.in","r",stdin);
    freopen("bird.out","w",stdout);
    int i,j,k,l,r,x,y,z;
    cin>>n;
    for(i=1;i<n;++i){
        cin>>x>>y;
        lk[x].push_back(y);
        lk[y].push_back(x);
    }
    dfs(1);
    dat at=h[1].top();
    printf("%d\n",at.v+at.k);
    return 0;
}